package com.wpf.system.service.impl;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wpf.system.common.utils.UploadUtils;
import com.wpf.system.entity.Notice;
import com.wpf.system.entity.vo.NoticeVO;
import com.wpf.system.service.NoticeService;
import com.wpf.system.mapper.NoticeMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author ferna
* @description 针对表【notice(公告表)】的数据库操作Service实现
* @createDate 2023-03-05 13:10:28
*/
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice>
    implements NoticeService{

    @Override
    public List<NoticeVO> getNoticeList(Long uid, String nid, String username, String title, String type, String status, Integer orderField, String startTime, String endTime, Integer page, Integer pageSize) {
        return this.baseMapper.getNoticeList(uid,nid,username,title,type,status,orderField,startTime,endTime,page,pageSize);
    }

    @Override
    public Boolean deleteNotice(Long id) {
        Notice notice = this.baseMapper.selectById(id);
        if(Convert.toBool(this.baseMapper.deleteById(notice))){
            //删除消息关联数据
            UploadUtils.deleteAllFiles(notice.getNo(),"notice");
            return true;
        }else {
            return false;
        }
    }
}




